﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcApplication5.DAM.Control;
using System.Data;
using MyFrameWork.Dam;
using MvcApplication5.Models;
using MyFrameWork.Common;
using MvcApplication5.Common;

namespace MvcApplication5.Controllers
{
    public class ControlController : MyController
    {
        //
        // GET: /Control/

        public ActionResult Head()
        {
            if (Session["LoginUser"] == null || Session["LoginUser"].ToString() == "")
            {
                return RedirectToAction("Login", "Admin");
            }
            return View();
        }
        public ActionResult Menu()
        {
            return View();
        }
        /// <summary>
        /// Menu取得
        /// </summary>
        /// <returns>查询结果</returns>
        [HttpPost]
        public ActionResult GetMenuList()
        {
            try
            {
                MenuModel menuModel = JsonUtility.Parse<MenuModel>(CommonUtility.GetAjaxDataString());

                ControlDAM controlDAM = new ControlDAM();

                DataSet ds = controlDAM.GetMenu(menuModel.parent_id.ToString());

                List<MenuModel> menuList = DataConvert<MenuModel>.ConvertModelToDataSet(ds);

                return Content(JsonUtility.ToJSON(menuList));
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
